<?php
include_once("connect.php");
include_once ("log_order.php"); //test!

//-----------------------------
//---include 
require( '../wp-load.php' );
//---get user_id
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
//---check if login
if ( !is_user_logged_in() || $user_id<1 ) { 
	$url = wp_login_url("index.php");
	echo "<script language='javascript' type='text/javascript'>";  
	echo "parent.location.href='$url'";  
	echo "</script>"; 
	exit;
} 
//-----------------------------

$email = $current_user->user_email;
$user_login = $current_user->user_login;

$idc_name = '';
$sex = '';
$country = '';
$city = '';
$address = '';
$postcode = '' ;
$tel = '';
$qq = '';
if ($user_id > 0){
	$sql = "select * from order_user where id=".$user_id;
	$rs=mysql_query($sql);
	if ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
		$idc_name=$row['idc_name'];
		$sex=$row['sex'];
		$country=$row['country'];
		$city=$row['city'];
		$address=$row['address'];
		$postcode=$row['postcode'];
		$tel=$row['tel'];
		$qq=$row['qq'];
	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="hello" />
<meta name="description" content="Hello" />
<title>order_user</title>

<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/fancybox.css" />

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/jquery.fancybox.js" type="text/javascript"></script>
<script src="js/jquery.message.js" type="text/javascript"></script>


<style type="text/css">
table{width:100%; margin:20px auto; border-collapse:collapse;}
table td{line-height:24px; padding:2px; padding-left:8px; border:1px solid #b6d6e6;}
.table_title{height:26px; line-height:26px; background:url(css/btn_bg.gif) repeat-x bottom; font-weight:bold; text-indent:.3em; outline:0;}
.table_label2{background:#e8f5fe; text-align:center; font-weight:bold;}
.table_label{background:#e8f5fe; text-align:right; }

.table_line{ text-align:center; font-weight:bold;}

.btn{height:24px; background:url(css/btn_bg.gif) repeat-x; padding:0 4px; font-size:12px; border:1px solid #ccc; cursor:pointer; margin-left:3px}
.input{border:1px solid #369; background:#ffc; padding:2px}
.msg{padding-left:30px; margin-top:20px}
textarea{font-size:12px}
</style>

<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(function(){
	$('#edit_form').ajaxForm({
		beforeSubmit: validate,
		success: function(msg){				
			if(msg > '0'){	
				$().message("修改成功");	
				self.location.reload(); 	
			}else{
				alert(msg);
			}
		}
	});

	$("#ch_pwd_btn").click(function(){
		$.fancybox({
			'type':'ajax',
			'href':'order_user_pw.php'
		});
	});


});
function validate(formData, jqForm, options) {  
	var array1 = ["idc_name", "city", "address", "tel"];
	var array2 = ["姓名","城市","地址","联系电话"];	
	for (var i=0; i < array1.length; i++) { 		
		var ivalue = document.getElementById( array1[i] ).value;
		//alert( ivalue );		
        if ( ivalue =='' ) { 
			alert(  "请输入"+array2[i]);
			document.getElementById( array1[i] ).focus();
            return false; 
        } 	
    }
	
	
	$().message("正在提交...");
}
</script>
</head>

<body>

<div id="main">

<form id="edit_form" action="order_do_user.php?action=edit" method="post">
  
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <thead>
    <tr class="table_title">
      <td colspan="6">我的帐户: 
	  </td>
    </tr>
  </thead>
  <tbody>
  
  	<tr>
      <td class="table_line"  colspan="6" alight=center>
		&nbsp; &nbsp; 
	  </td>
    </tr>   
	
	<tr>
      <td class="table_label" width="10%">登录用户名：</td>
      <td class="edit" width="40%" colspan="2">
		<?php echo $user_login; ?>
	  </td>
    </tr>
	
	<tr>
      <td class="table_label" >email：</td>
      <td class="edit" colspan="2">
		<?php echo $email; ?>
	  </td>	  
    </tr>
 
	
    <tr>
      <td class="table_label" width="10%">姓名：</td>
      <td class="edit" width="40%" colspan="2">
		<input type="text" class="input2" id="idc_name" name="idc_name" maxlength="60" value="<?php echo $idc_name; ?>" />
	  </td>
    </tr>
	
	<tr>
      <td class="table_label" >性别：</td>
      <td class="edit" colspan="2">
		<select id="sex" name="sex">				
				<option value="女" <?php if ($sex=='女') echo 'selected'; ?>>女</option>
				<option value="男" <?php if ($sex=='男') echo 'selected'; ?>>男</option>
			</select>
	  </td>	  
    </tr>
	
	<tr>
      <td class="table_label" >国家/地区：</td>
      <td class="edit" colspan="2"><select id="country" name="country">
					<option value="德国" <?php if ($country=='德国') echo 'selected'; ?>>德国</option>
					<option value="荷兰" <?php if ($country=='荷兰') echo 'selected'; ?>>荷兰</option>
					<option value="中国大陆" <?php if ($country=='中国大陆') echo 'selected'; ?>>中国大陆</option>
					<option value="香港" <?php if ($country=='香港') echo 'selected'; ?>>香港</option>
					<option value="澳门" <?php if ($country=='澳门') echo 'selected'; ?>>澳门</option>
					<option value="台湾" <?php if ($country=='台湾') echo 'selected'; ?>>台湾</option>                
				</select>
		</td>	  
    </tr>	
	
	<tr>
      <td class="table_label" >城市：</td>
      <td class="edit"  colspan="2">
		<input type="text" class="input2" id="city" name="city" maxlength="60" value="<?php echo $city; ?>" />
	  </td>	  
    </tr>
	
	<tr>
      <td class="table_label" >地址：</td>
      <td class="edit" colspan="2">
		<textarea type="text" class="input3" id="address" name="address" rows="2" cols="44"><?php echo $address; ?></textarea>
	  </td>	  
    </tr>
	
	<tr>
      <td class="table_label" >邮编：</td>
      <td class="edit" colspan="2">
		<input type="text" class="input2" id="postcode" name="postcode" maxlength="60" value="<?php echo $postcode; ?>" />
	  </td>	  
    </tr>

	<tr>
      <td class="table_label" >联系电话：</td>
      <td class="edit" colspan="2">
		<input type="text" class="input2" id="tel" name="tel" maxlength="60" value="<?php echo $tel; ?>" />
	  </td>	  
    </tr>

	<tr>
      <td class="table_label" >联系QQ：</td>
      <td class="edit" colspan="2">
		<input type="qq" class="input2" id="qq" name="qq" maxlength="60" value="<?php echo $qq; ?>" />
	  </td>	  
    </tr>

	<tr>
      <td class="table_line"  colspan="6" aligh=center>
		&nbsp; &nbsp; 
	  </td>
    </tr> 

	<tr>
      <td class="table_line"  colspan="6" aligh=center>
	  <input type="hidden" class="input2" name="user_id"  value="<?php echo $user_id; ?>" />	  
	  <input type="submit" class="btn" value="提 交"/>	 &nbsp; &nbsp; 
	  
	  <input type="button" class="btn" id="ch_pwd_btn" value="修改密码" />
	  </td>
    </tr> 
	
  </tbody>
</table>

</form>
<br/>


</div>

</body>
</html>